import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
// 下面两行代码是进度条动画
import 'nprogress/nprogress.css'
import NProgress from 'nprogress'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/maxindex',
      name: 'maxindex',
      meta: { title: '首页' },
      component: () => import('../components/MaxIndex.vue'),

      children: [
        // 樊鹏
        {
          path: '/maxindex/myinquire',
          name: 'myinquire',
          meta: { title: '走步' },
          component: () => import('../views/FanPeng/MyInquire.vue'),
        },
        {
          path: '/maxindex/myexercise',
          name: 'myexercise',
          meta: { title: '运动' },
          component: () => import('../views/FanPeng/MyExercise.vue'),
        },
        {
          path: '/maxindex/myheartrate',
          name: 'myheartrate',
          meta: { title: '心率' },
          component: () => import('../views/FanPeng/MyHeartrate.vue'),
        },
        {
          path: '/maxindex/mysleep',
          name: 'mysleep',
          meta: { title: '睡眠' },
          component: () => import('../views/FanPeng/MySleep.vue'),
        },
        {
          path: '/maxindex/sleepreader',
          name: 'sleepreader',
          meta: { title: '明细' },
          component: () => import('../views/FanPeng/SleepReader.vue'),
        },
        {
          path: '/maxindex/bianji/',
          name: 'bianji',
          meta: { title: '编辑' },
          component: () => import('../views/FanPeng/BianJi.vue'),
        },
        {
          path: '/maxindex/mytemperature.vue',
          name: 'mytemperature.vue',
          meta: { title: '体温' },
          component: () => import('../views/FanPeng/MyTemperature.vue'),
        },
        {
          path: '/maxindex/examine.vue',
          name: 'examine.vue',
          meta: { title: '体温明细' },
          component: () => import('../views/FanPeng/Examine.vue'),
        },
        {
          path: '/maxindex/compile/',
          name: 'compile',
          meta: { title: '详情' },
          component: () => import('../views/FanPeng/Compile.vue'),
        },
        {
          path: '/maxindex/compiletwo/',
          name: 'compiletwo',
          meta: { title: '详情' },
          component: () => import('../views/FanPeng/CompileTwo.vue'),
        },
        {
          path: '/maxindex/compilethree.vue/',
          name: 'compilethree.vue',
          meta: { title: '详情' },
          component: () => import('../views/FanPeng/CompileThree.vue'),
        },


        // 刘坤 
        {
          path: '/maxindex/keshi',
          name: 'keshi',
          meta: { title: '科室管理' },
          component: () => import('../views/LiuKun/KeShi.vue'),
        },
        {
          path: '/maxindex/yiyuan',
          name: 'yiyuan',
          meta: { title: '医院管理' },
          component: () => import('../views/LiuKun/YiYuan.vue'),
        },
        {
          path: '/maxindex/yiyuandex',
          name: 'yiyuandex',
          meta: { title: '医院详情页' },
          component: () => import('../views/LiuKun/yiyuan/YiYuandex.vue'),
        },
        {
          path: '/maxindex/yisheng',
          name: 'yisheng',
          meta: { title: '医生管理' },
          component: () => import('../views/LiuKun/YiSheng.vue'),
        },
        {
          path: '/maxindex/zengjia',
          name: 'zengjia',
          meta: { title: '添加医生' },
          component: () => import('../views/LiuKun/yisheng/ZengJia.vue'),
        },
        {
          path: '/maxindex/YiShengxiangqing',
          name: 'YiShengxiangqing',
          meta: { title: '医生详情' },
          component: () => import('../views/LiuKun/yisheng/YiShengxiangqing.vue'),
        },
        {
          path: '/maxindex/yiqing',
          name: 'yiqing',
          meta: { title: '疫情管理' },
          component: () => import('../views/LiuKun/YiQing.vue'),
        },
        {
          path: '/maxindex/yiqingxiangqing',
          name: 'yiqingxiangqing',
          meta: { title: '添加疾病' },
          component: () => import('../views/LiuKun/yiqing/YiQingixangqing.vue'),
        },
        {
          path: '/maxindex/shezhi',
          name: 'shezhi',
          meta: { title: '预约设置' },
          component: () => import('../views/LiuKun/SheZhi.vue'),
        },
        {
          path: '/maxindex/guahao',
          name: 'guahao',
          meta: { title: '预约查询（挂号）' },
          component: () => import('../views/LiuKun/GuaHao.vue'),
        },
        {
          path: '/maxindex/tijian',
          name: 'tijian',
          meta: { title: '预约查询（体检）' },
          component: () => import('../views/LiuKun/TiJian.vue'),
        },

        // 张伟
        {
          path: '/maxindex/LanMu',
          name: 'LanMu',
          meta: { title: '栏目管理' },
          component: () => import('../views/ZhangWei/LanMu.vue'),
          children: [
            {
              path: '/maxindex/LanMu/LanMuEdit',
              name: 'LanMuEdit',
              meta: { title: '编辑栏目' },
              component: () => import('../views/ZhangWei/LanMuEdit.vue'),
            },
          ]
        },
        {
          path: '/maxindex/GuangGao',
          name: 'GuangGao',
          meta: { title: '广告管理' },
          component: () => import('../views/ZhangWei/GuangGao.vue'),
        },
        {
          path: '/maxindex/ShenHeList',
          name: 'ShenHeList',
          meta: { title: '审核列表' },
          component: () => import('../views/ZhangWei/ShenHeList.vue'),
        },
        {
          path: '/maxindex/ZiXun',
          name: 'ZiXun',
          meta: { title: '资讯管理' },
          component: () => import('../views/ZhangWei/ZiXun.vue'),

        },
        {
          path: '/maxindex/AddGuangGao',
          name: 'AddGuangGao',
          meta: { title: '添加广告' },
          component: () => import('../views/ZhangWei/AddGuangGao.vue'),
        },
        {
          path: '/maxindex/AddZiXun',
          name: 'AddZiXun',
          meta: { title: '添加资讯' },
          component: () => import('../views/ZhangWei/AddZiXun.vue'),
        },
        {
          path: '/maxindex/CheckZiXun',
          name: 'CheckZiXun',
          meta: { title: '查看资讯' },
          component: () => import('../views/ZhangWei/CheckZiXun.vue'),
        },
        {
          path: '/maxindex/ShenHeZiXun',
          name: 'ShenHeZiXun',
          meta: { title: '审核资讯' },
          component: () => import('../views/ZhangWei/ShenHeZiXun.vue'),
        },
        // 404 路由

        // {
        //   path: '/:id(.*)',
        //   component: () => import('../components/404/NotFond.vue'),
        // },
        // 路由重定向
        // {
        //   path: '/maxindex/ZiXun',
        //   redirect: 'maxindex/ZiXun/run'
        // }



        // 蔺梦德

        {
          path: '/maxindex/UserStatistics',
          name: 'UserStatistics',
          meta: { title: '用户统计' },
          component: () => import('../views/linmengde/UserStatistics.vue'),
        },
        {
          path: '/maxindex/RegistrationStatistics',
          name: 'RegistrationStatistics',
          meta: { title: '挂号统计' },
          component: () => import('../views/linmengde/RegistrationStatistics.vue'),
        },
        {
          path: '/maxindex/PhysicalStatistics',
          name: 'PhysicalStatistics',
          meta: { title: '体检统计' },
          component: () => import('../views/linmengde/PhysicalStatistics.vue'),
        },
        {
          path: '/maxindex/InquiryStatistics',
          name: 'InquiryStatistics',
          meta: { title: '问诊统计' },
          component: () => import('../views/linmengde/InquiryStatistics.vue'),
        },
        {
          path: '/maxindex/SalesStatistics',
          name: 'SalesStatistics',
          meta: { title: '销售统计' },
          component: () => import('../views/linmengde/SalesStatistics.vue'),
        },
        {
          path: '/maxindex/edititem',
          name: 'edititem',
          meta: { title: '编辑用户' },
          component: () => import('../views/linmengde/operation/Edititem.vue'),
        },

        // 李焕琴
        // 品类 - 获取数据
        {
          path: '/maxindex/class',
          name: 'class',
          meta: { title: '品类管理' },
          component: () => import('../views/LiHuanQin/Class.vue'),
        },
        // 品类 - 编辑
        {
          path: '/maxindex/classedit',
          name: 'classedit',
          meta: { title: '编辑' },
          component: () => import('../views/LiHuanQin/Classedit.vue'),
        },
        // 品类 - 查看
        {
          path: '/maxindex/classwatch',
          name: 'classwatch',
          meta: { title: '查看' },
          component: () => import('../views/LiHuanQin/Classwatch.vue'),
        },
        // 商品 - 获取数据
        {
          path: '/maxindex/goods',
          name: 'goods',
          meta: { title: '商品管理' },
          component: () => import('../views/LiHuanQin/Goods.vue'),
        },
        // 商品 - 编辑
        {
          path: '/maxindex/goodsedit',
          name: 'goodsedit',
          meta: { title: '编辑' },
          component: () => import('../views/LiHuanQin/Goodsedit.vue'),
        },
        // 商品 - 查看
        {
          path: '/maxindex/goodswatch',
          name: 'goodswatch',
          meta: { title: '查看' },
          component: () => import('../views/LiHuanQin/Goodswatch.vue'),
        },
        // 订单
        {
          path: '/maxindex/order',
          name: 'order',
          meta: { title: '订单管理' },
          component: () => import('../views/LiHuanQin/Order.vue'),
        },
        // 订单 - 待付款
        {
          path: '/maxindex/waitpay',
          name: 'waitpay',
          meta: { title: '待付款' },
          component: () => import('../views/LiHuanQin/Waitpay.vue'),
        },
        // 订单 - 待发货
        {
          path: '/maxindex/waitgoods',
          name: 'waitgoods',
          meta: { title: '待发货' },
          component: () => import('../views/LiHuanQin/waitgoods.vue'),
        },
        // 订单 - 待付款
        {
          path: '/maxindex/finishgoods',
          name: 'finishgoods',
          meta: { title: '已发货' },
          component: () => import('../views/LiHuanQin/Finishgoods.vue'),
        },
        // s搜索
        {
          path: '/maxindex/search',
          name: 'search',
          meta: { title: '已发货' },
          component: () => import('../views/LiHuanQin/Search.vue'),
        },
        {
          path: '/maxindex/quit',
          name: 'quit',
          meta: { title: '退出页面' },
          component: () => import('../components/Quit.vue'),
        },
      ]
    },
    // 登录页面
    {
      path: '/login',
      name: 'login',
      meta: { title: '登录' },
      component: () => import('../components/Login.vue'),
    },
    // 404 路由
    {
      path: '/:id(.*)',
      meta: { title: '路径未找到' },
      component: () => import('../components/404/NotFond.vue'),
    },
    // 路由重定向
    {
      path: '/',
      redirect: '/login'
    }

  ]
  ,
})

export default router

// todo   路由前置守卫
router.beforeEach((to, form, next) => {

  next();
  // 进度条动画
  NProgress.start();

})

//todo   路由后置守卫
router.afterEach((to, form) => {
  document.title = to.meta.title;
  // 进度条动画
  NProgress.done();
})
